package com.cn.kehong.controller;

import com.cn.kehong.api.IFrontDisplayService;
import com.cn.kehong.domain.FrontDisplay;
import com.cn.kehong.domain.FrontDisplayVo;
import com.cn.kehong.utils.CommonUtil;
import com.cn.kehong.utils.JsonResponse;
import com.cn.kehong.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created On : 2024/1/12.
 * <p>
 * Author : Huiyan
 * <p>
 * Description: FrontDisplayController
 */

@Controller
@RequestMapping("/front")
public class FrontDisplayController {

    @Autowired
    private IFrontDisplayService frontDisplayService;

    @ResponseBody
    @RequestMapping("/getFrontDisplay/{frontToken}")
    public JsonResponse<FrontDisplayVo> getDeviceData(QueryForm queryForm, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<FrontDisplayVo> response = new JsonResponse<FrontDisplayVo>();
        FrontDisplayVo frontDisplay = frontDisplayService.getFrontDisplay(queryForm);
        response.setResult(frontDisplay);
        response.setSuccess(true);
        return response;
    }


    @ResponseBody
    @RequestMapping("/getFrontDisplay")
    public JsonResponse<FrontDisplayVo> getBoardDeviceData(QueryForm queryForm) throws Exception {
        JsonResponse<FrontDisplayVo> response = new JsonResponse<FrontDisplayVo>();
        FrontDisplayVo frontDisplay = frontDisplayService.getFrontDisplay(queryForm);
        response.setResult(frontDisplay);
        response.setSuccess(true);
        return response;
    }


    @ResponseBody
    @RequestMapping("/addOrUpdateFrontDisplay/{frontToken}")
    public JsonResponse<String> addOrUpdateFrontDisplay(@RequestBody FrontDisplayVo frontDisplayVo, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = frontDisplayService.addOrUpdateFrontDisplay(frontDisplayVo);
        return CommonUtil.getResponseData(response,result);
    }

    @ResponseBody
    @RequestMapping("/addFrontDisplay/{frontToken}")
    public JsonResponse<String> addFrontDisplay(FrontDisplay frontDisplay, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = frontDisplayService.addFrontDisplay(frontDisplay);
        return CommonUtil.getResponseData(response,result);
    }

    @ResponseBody
    @RequestMapping("/updateFrontDisplay/{frontToken}")
    public JsonResponse<String> updateFrontDisplay(FrontDisplay frontDisplay, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = frontDisplayService.updateFrontDisplay(frontDisplay);
        return CommonUtil.getResponseData(response,result);
    }

    @ResponseBody
    @RequestMapping("/deleteFrontDisplay/{frontToken}")
    public JsonResponse<String> deleteFrontDisplay(String id, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = frontDisplayService.deleteFrontDisplay(id);
        return CommonUtil.getResponseData(response,result);
    }

}
